package com.practice.pagehelper.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.practice.pagehelper.dto.req.BasePageReqDto;
import com.practice.pagehelper.entity.PersonOrgRelEntity;
import com.practice.pagehelper.mapper.PersonOrgRelMapper;
import com.practice.pagehelper.service.PersonOrgRelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description : 人员组织关系实现类
 * @Author : guxuemin
 * @Version : V1.0.0
 * @Date : 2021/9/18 15:43
 */
@Service
public class PersonOrgRelServiceImpl implements PersonOrgRelService {
    @Resource
    private PersonOrgRelMapper personOrgRelMapper;

    @Override
    public PersonOrgRelEntity queryPerson(PersonOrgRelEntity personOrgRelEntity) {
        return personOrgRelMapper.selectOne(personOrgRelEntity);
    }

    @Override
    public List<PersonOrgRelEntity> queryPagePerson(BasePageReqDto reqDto) {
        Page<PersonOrgRelEntity> page = PageHelper.startPage(1, 2);
        Example queryCondition = new Example(PersonOrgRelEntity.class);
        queryCondition.orderBy("createTime");
        List<PersonOrgRelEntity> relEntityList = personOrgRelMapper.selectByExample(queryCondition);
        return relEntityList;
    }
}
